﻿namespace LoginSample.Controllers
{
    using LoginSample.Models;

    public class LoginController
    {
        public IUserDao UserDao { get; set; }

        public bool Register(string username, string password, string passwordConfirmation)
        {
            var existingUser = this.UserDao.GetByUsername(username);
            if (existingUser == null)
            {
                if (password.Equals(passwordConfirmation))
                {
                    var user = new User(username, password);
                    this.UserDao.Add(user);
                    return true;
                }
            }

            return false;
        }
    }
}
